<?php

class IndexController extends ControllerBase
{

    public function indexAction()
    {
        echo 111;
    }
    public function sanAction(){
        echo 225;
    }

    public function curlAction(){
        $curlobj = curl_init();
        //执行后不直接打印出
//        curl_setopt($curlobj, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curlobj, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($curlobj, CURLOPT_URL, "https://www.baidu.com");
        $result = curl_exec($curlobj);
        curl_close($curlobj);
        var_dump($result);
    }
    public function yieldAction(){

        $a = $this->test();
        foreach ($a as $item){
            $this->outPut($item);
        }

    }
    public function test(){
        $b = (yield $this->curls());
    }
    public function outPut($a){
        var_dump($a);
    }

    public function curls(){
        return 11;
        $a1 = fopen('index.php','r');
        $a2 = fopen('temp/test.txt','w+');
        $len = stream_copy_to_stream($a1,$a2);
        $curlobj = curl_init();
        //执行后不直接打印出
//        curl_setopt($curlobj, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curlobj, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($curlobj, CURLOPT_URL, "https://www.baidu.com");
        $result = curl_exec($curlobj);
        curl_close($curlobj);
//        yield;
//        var_dump($result);
    }

}

